package com.dcy.iterator;

import java.util.Iterator;
import java.util.List;

/**
 * @Author：dcy
 * @Description:
 * @Date: 2021/1/28 9:27
 */
public class InfoCollegeIterator implements Iterator<Department> {

    /**
     * 信息工厂学院是以List方式存储
     */
    List<Department> departments;
    /**
     * 索引
     */
    int index = -1;

    public InfoCollegeIterator(List<Department> departments) {
        this.departments = departments;
    }

    /**
     * 判断list种还有没有下一个元素
     *
     * @return
     */
    @Override
    public boolean hasNext() {
        if (index >= departments.size() - 1) {
            return false;
        } else {
            index += 1;
            return true;
        }
    }

    @Override
    public Department next() {
        return departments.get(index);
    }

    @Override
    public void remove() {

    }
}
